package com.frame.sqlsession;

import com.frame.config.Configuration;
import com.frame.sqlsession.support.DefaultSqlSessionFactory;
import com.frame.utils.XMLConfigBuilder;

import java.io.InputStream;

/**
 * @Description 用于创建一个 SqlSessionFactory 对象
 * @Author Mokairui
 * @Since 2021/11/27
 */
public class SqlSessionFactoryBuilder {

    /**
     * 根据参数的字节输入流来构建一个 SqlSessionFactory 共厂
     * @param configLocation
     * @return
     */
    public SqlSessionFactory build(InputStream configLocation) {
        Configuration config = XMLConfigBuilder.loadConfiguration(configLocation);
        return new DefaultSqlSessionFactory(config);
    }
}
